import {createSlice} from "@reduxjs/toolkit";
const user = createSlice({
    name:'user',
    //初始化状态
    initialState:{
        me:{username:'',avatar:''},   //当前用户
        userlist:''  //在线用户
    },
    reducers:{
        User(state,action){
            state.me.username = action.payload.username;
            state.me.avatar = action.payload.avatar;
        },
        Userlist(state,action){
            state.userlist = action.payload
        }
    }
})

//到处action函数
export const {User,Userlist} = user.actions


export default user.reducer;